package com.ph.irp.base.assistantmaterial.service.impl;

import java.util.List;
import com.ph.irp.base.assistantmaterial.dao.PBaseAssistantmaterialCultureDAO;
import com.ph.irp.base.assistantmaterial.service.PBaseAssistantmaterialCultureService;
import com.ph.irp.model.PBaseAssistantmaterialCulture;

/**
 * 辅助资料-文化程度service
 * 
 * @author yanjian@phinfoservices.com
 * 
 */
public class PBaseAssistantmaterialCultureServiceImpl implements
		PBaseAssistantmaterialCultureService {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3165077432385090172L;
	private PBaseAssistantmaterialCultureDAO cultureDAOProxy = null;

	public PBaseAssistantmaterialCultureDAO getCultureDAOProxy() {
		return cultureDAOProxy;
	}

	public void setCultureDAOProxy(
			PBaseAssistantmaterialCultureDAO cultureDAOProxy) {
		this.cultureDAOProxy = cultureDAOProxy;
	}

	@Override
	public void addCulture(PBaseAssistantmaterialCulture culture)
			throws Throwable {

		cultureDAOProxy.addAssistantmaterialCulture(culture);

	}

	@Override
	public void deleteCulture(String[] cultureIds) throws Throwable {

		for (String cultureId : cultureIds)
			cultureDAOProxy.deleteAssistantmaterialCulture(cultureId);

	}

	@Override
	public PBaseAssistantmaterialCulture getCultureById(int cultureId)
			throws Throwable {

		return cultureDAOProxy.getAssistantmaterialCultureById(cultureId);

	}

	@Override
	public List<PBaseAssistantmaterialCulture> getCultures(
			PBaseAssistantmaterialCulture culture) throws Throwable {

		if (culture == null) {
			return cultureDAOProxy.getAllAssistantmaterialCultures();
		} else {
			String cultureCode = culture.getCultureCode();
			String cultureName = culture.getCultureName();
			if ((cultureCode != null && !cultureCode.trim().equals(""))
					&& (cultureName != null && !cultureName.trim().equals(""))) {
				return cultureDAOProxy.getAssistantmaterialCulturesByCodeAndName(
						cultureCode, cultureName);
			} else if (cultureCode != null && !cultureCode.trim().equals("")) {
				return cultureDAOProxy
						.getAssistantmaterialCulturesByCode(cultureCode);
			} else if (cultureName != null && !cultureName.trim().equals("")) {
				return cultureDAOProxy
						.getAssistantmaterialCulturesByName(cultureName);
			} else {
				return cultureDAOProxy.getAllAssistantmaterialCultures();
			}
		}

	}

	@Override
	public List<PBaseAssistantmaterialCulture> getAllCultures()
			throws Throwable {
		return cultureDAOProxy.getAllAssistantmaterialCultures();
	}

	@Override
	public List<PBaseAssistantmaterialCulture> getCulturesByCode(
			String cultureCode) throws Throwable {
		return cultureDAOProxy.getAssistantmaterialCulturesByCode(cultureCode);
	}

	@Override
	public List<PBaseAssistantmaterialCulture> getCulturesByCodeAndName(
			String cultureCode, String cultureName) throws Throwable {
		return cultureDAOProxy.getAssistantmaterialCulturesByCodeAndName(cultureCode, cultureName);
	}

	@Override
	public List<PBaseAssistantmaterialCulture> getCulturesByNmae(
			String cultureName) throws Throwable {
		return cultureDAOProxy.getAssistantmaterialCulturesByName(cultureName);
	}

	@Override
	public void updateCulture(PBaseAssistantmaterialCulture culture)
			throws Throwable {

		cultureDAOProxy.updateAssistantmaterialCulture(culture);

	}

}
